<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>修改项目</title>
  <link rel="stylesheet" href="../../../layui/css/layui.css">
  <script src="../../../layui/layui.js"></script>
    <script type="text/javascript" src="../../../js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="../../../js/main.js"></script>
    <link rel="stylesheet" href="../../../js/zyupload/skins/zyupload-1.0.0.min.css " type="text/css">
    <script type="text/javascript" src="../../../js/zyupload/zyupload-1.0.0.min.js"></script>
</head>
<style type="text/css">
 body{
  height: 100%;
  width: 100%;
 }
 .layui-form-label{width: 130px}
 .btn {
    background-color: #e5e5e5;
    background-image: none;
    filter: none;
    border: 0;
    padding: 7px 14px;
    text-shadow: none;
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333333;
    cursor: pointer;
    outline: none;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-border-radius: 0 !important;
    -moz-border-radius: 0 !important;
    border-radius: 0 !important;
}
.layui-input-inline{width: 214px !important}
</style>

<body>
 <!-- 内容主体区域 -->
 <div class="x-body layui-anim layui-anim-up">
  <div class="layui-fluid">
  
    <form class="layui-form layui-form-pane1" lay-filter="first" >
        <div class="layui-form-item">
        </div>
      <div class="layui-form-item">
          <div class="layui-inline">
         <label class="layui-form-label"><span class="text-error">*</span>项目名称：</label>
         <div class="layui-input-inline">
          <input name="serviceName" id="serviceName" placeholder="请输入" value="" class="layui-input">
          </div>
          </div>

      </div>
        <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span class="text-error"></span>选择类别：</label>
            <div class="layui-input-inline">
                <select name="parentSeriesId" id="parentSeriesId" lay-verify="required" lay-search=""  lay-filter="parentSerSelect">

                </select>
            </div>

        </div>

            <div class="layui-inline">
                <label class="layui-form-label"><span class="text-error"></span>选择系列：</label>
                <div class="layui-input-inline">
                    <select name="serviceSeriesId" id="serviceSeriesId" lay-verify="required" lay-search="">

                    </select>
                </div>

            </div>
        </div>
       <div class="layui-form-item">
           <label class="layui-form-label">卡类别：</label>
           <div class="layui-input-inline">
               <select name="cardType" id="cardType"   lay-verify="required" lay-search="" lay-filter="test">
                   <option value="0">次卡</option>
                   <option value="1">月卡</option>
                   <option value="2">季卡</option>
                   <option value="3">半年卡</option>
                   <option value="4">年卡</option>
               </select>
           </div>


           <input type="hidden" id="expiredTime" name="expiredTime" value=""/>
           <!--<div class="layui-inline" id="expiredTimeType">-->
               <!--<label class="layui-form-label">有效期：</label>-->
               <!--<div class="layui-input-inline">-->
                   <!--<input name="expiredTime" id="expiredTime" placeholder="请输入"  value="" class="layui-input">-->
               <!--</div>-->
           <!--</div>-->
           <div class="layui-inline" id="periodPerTimeType">
               <label class="layui-form-label">单次时长(分)：</label>
               <div class="layui-input-inline">
                   <input name="periodPerTime" id="periodPerTime" placeholder="请输入"  value="" class="layui-input">
               </div>
           </div>
       </div>



        <div class="layui-form-item">
        <div class="layui-inline"  id="pricePerTimeType">
            <label class="layui-form-label">单次价格：</label>
            <div class="layui-input-inline">
                <input name="pricePerTime" id="pricePerTime" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline"  id="priceMarketType">
            <label class="layui-form-label">市场价格：</label>
            <div class="layui-input-inline">
                <input name="priceMarket" id="priceMarket" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        </div>
        <div class="layui-form-item">
        <div class="layui-inline"  id="priceType">
            <label class="layui-form-label" id="priceLabel">办卡价格：</label>
            <div class="layui-input-inline">
                <input name="price" id="price" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">回访天数：</label>
            <div class="layui-input-inline">
                <input name="returnVisit" id="returnVisit" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        </div>
        <div class="layui-form-item" id="timeTotalType">
            <label class="layui-form-label">包含次数：</label>
            <div class="layui-input-inline">
                <input name="timeTotal" id="timeTotal" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">简介：</label>
            <div class="layui-input-inline">

                <textarea name="description" id="description" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item"  id="img1">
            <label class="layui-form-label">项目照片</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg1">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo1" width=200px height=130px>
                    <p id="demoText"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item"  id="img2">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg2">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo2" width=200px height=130px>
                    <p id="demoText2"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="img3">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg3">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo3" width=200px height=130px>
                    <p id="demoText3"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item"  id="img4">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg4">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo4" width=200px height=130px>
                    <p id="demoText4"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="img5">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg5">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo5" width=200px height=130px>
                    <p id="demoText5"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="img6">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg6">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo6" width=200px height=130px>
                    <p id="demoText6"></p>
                </div>
            </div>
        </div>

        <!--<div id="zyupload" class="zyupload"></div>-->




        <div class="layui-form-item">
            <label class="layui-form-label">是否停用：</label>
            <div class="layui-input-block">
                <input type="checkbox" name="recordStatus"  id="recordStatus" lay-skin="switch"  lay-text="ON|OFF">
            </div>
        </div>

        <div class="layui-form-item" style="margin-left: 140px;">
            <!--<p id="btnGroup" class="pull-right">-->
                <button class="layui-btn save"  lay-submit="" lay-filter="*" >保存</button>
                <button class="layui-btn quxiao" >取消</button>
            <!--</p>-->
        </div>
        <input name="recordId" id="recordId"  type="hidden"  class="layui-input">
        <input name="storeId" id="storeId"  type="hidden"  class="layui-input">
        <!--<input name="picRecordId1" id="picRecordId1" placeholder="请输入"  value="" class="layui-input">-->
        <input name="picRecordId1" id="picRecordId1"  type="hidden"  class="layui-input">
        <input name="picRecordId2" id="picRecordId2"  type="hidden"  class="layui-input">
        <input name="picRecordId3" id="picRecordId3"  type="hidden"  class="layui-input">
        <input name="picRecordId4" id="picRecordId4"  type="hidden"  class="layui-input">
        <input name="picRecordId5" id="picRecordId5"  type="hidden"  class="layui-input">
        <input name="picRecordId6" id="picRecordId6"  type="hidden"  class="layui-input">
    </form>
  </div>
  </div>
  </body>
  </html>
<script type="text/javascript">



    //重新渲染表单

    function renderForm(){

        layui.use('form', function(){

            var form = layui.form;
            form.render();

        });

    }



    function child(data){
        var $ = layui.jquery;

        var serviceSeriesId = data.serviceSeriesId;
        console.log('serviceSeriesId++++++++++++++++++++++++++++'+serviceSeriesId);
        var recordId=data.recordId;
        $('#recordId').val(recordId);
        console.log('recordId='+$('#recordId').val(recordId));




        $.ajax({
            url:"/hy/basic/pictures/getPictures",
            type:"get",
            data:{"masterDataId":recordId,"recordType":2,"picType":0},
            async: false,
            dataType:"json",
            success:function(dataJson){
                console.log('返回类别'+dataJson.data.length);

                console.log('返回类别'+dataJson.data);
                var picSize=dataJson.data.length;

                $.each(dataJson.data, function (i, n) {
                    console.log('第几个了'+i);
                    console.log(n.picUrl);
                    console.log('#demo'+i++);
                    $('#demo'+i).attr('src', 'http://localhost:8080'+n.picUrl);
                    console.log('#picRecordId'+i);
                    $('#picRecordId'+i).val(n.recordId);

                    console.log("#picRecordId"+i+"==========++++++++++++++++++++"+$('#picRecordId'+i).val());

                    var  recordId=$("#picRecordId1").val();

                    console.log("JquerRecordId"+recordId);
                });




                renderForm();

                $('#parentSeriesId').val(dataJson.data.parentSeries);
            },
            error:function(){
                alert("驳回异常")
            }
        });





        $.ajax({
            url:"/hy/basic/serviceSeries/queryParentServiceSeries",
            type:"get",
            data:{"serviceSeriesId":serviceSeriesId},
            dataType:"json",
            success:function(dataJson){
                console.log('返回类别'+dataJson.data.parentSeries);
                var selDom = $("#parentSeriesId");//根据id获取select的jquery对象

                var sonSele = $("#serviceSeriesId");//根据id获取select的jquery对象

                $.each(dataJson.data.seriesList, function (i, n) {
                    // $("#parentSeriesId").append("<option value='Value'>Text</option>");
                    selDom.append("<option value="+n.recordId+">"+n.seriesName+"</option>");//添加option
                    console.log(n.seriesName);
                });

                $.each(dataJson.data.sonSeriesList, function (i, n) {
                    // $("#parentSeriesId").append("<option value='Value'>Text</option>");
                    sonSele.append("<option value="+n.recordId+">"+n.seriesName+"</option>");//添加option
                    console.log(n.seriesName);
                });

                renderForm();

                $('#parentSeriesId').val(dataJson.data.parentSeries);
            },
            error:function(){
                alert("驳回异常")
            }
        });






        $('#serviceSeriesId').val(serviceSeriesId);



        var cardType = data.cardType;
        $('#cardType').val(cardType);

        if(cardType == 0){
            $("#pricePerTimeType").show();
            $("#priceType").show();

            $("#priceMarketType").hide();
            $("#timeTotalType").hide();
            $("#priceLabel").text("办卡价格(元)");


        }else if(cardType == 1){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }else if(cardType == 2){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }else if(cardType == 3){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }else if(cardType == 4){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }




        var serviceName = data.serviceName;
        $('#serviceName').val(serviceName);
        console.log("serviceName++++++++++++++++++"+$('#serviceName').val());
        console.log("#picRecordId++++++++++++++++++++"+$('#picRecordId1').val());
        var expiredTime = data.expiredTime;
        $('#expiredTime').val(expiredTime);

        var recordStatus = data.recordStatus;
        if(recordStatus==1){
            $("#recordStatus").attr("checked",'checked');
        }
        var periodPerTime = data.periodPerTime;
        $('#periodPerTime').val(periodPerTime);

        var pricePerTime = data.pricePerTime;
        $('#pricePerTime').val(pricePerTime);

        var priceMarket = data.priceMarket;
        $('#priceMarket').val(priceMarket);

        var price = data.price;
        $('#price').val(price);

        var returnVisit = data.returnVisit;
        $('#returnVisit').val(returnVisit);

        var timeTotal = data.timeTotal;
        $('#timeTotal').val(timeTotal);

        var description = data.description;
        $('#description').val(description);

        $('#storeId').val(data.storeId);


        // $("#zyupload").zyUpload({
        //     width            :   "650px",                 // 宽度
        //     height           :   "",                 // 宽度
        //     itemWidth        :   "140px",                 // 文件项的宽度
        //     itemHeight       :   "115px",                 // 文件项的高度
        //     url              :   "/hy/basic/pictures/fileUpload?record_type=4"+"&masterDataId="+$("#picRecordId1").val(),              // 上传文件的路径
        //     fileType         :   ["jpg","png","txt","js","exe"],// 上传文件的类型
        //     fileSize         :   51200000,                // 上传文件的大小
        //     multiple         :   true,                    // 是否可以多个文件上传
        //     dragDrop         :   true,                    // 是否可以拖动上传文件
        //     tailor           :   true,                    // 是否可以裁剪图片
        //     del              :   true,                    // 是否可以删除文件
        //     finishDel        :   false,  				  // 是否在上传文件完成后删除预览
        //     data:{dataID:123},
        //     /* 外部获得的回调接口 */
        //     onSelect: function(selectFiles, allFiles){    // 选择文件的回调方法  selectFile:当前选中的文件  allFiles:还没上传的全部文件
        //         console.info("当前选择了以下文件：");
        //         console.info(selectFiles);
        //     },
        //     onDelete: function(file, files){              // 删除一个文件的回调方法 file:当前删除的文件  files:删除之后的文件
        //         console.info("当前删除了此文件：");
        //         console.info(file.name);
        //     },
        //     onSuccess: function(file, response){          // 文件上传成功的回调方法
        //         console.info("此文件上传成功：");
        //         console.info(file.name);
        //         console.info("此文件上传到服务器地址：");
        //         console.info(response);
        //         response = JSON.parse(response);
        //         var list = response.data;
        //         var picList = JSON.parse($(".picList").val());
        //         for(index in list){
        //             console.log(list[index].recordId);
        //             picList.push(list[index].recordId);
        //         }
        //         $(".picList").val(JSON.stringify(picList));
        //         $("#uploadInf").append("<p>上传成功，文件地址是：" + response + "</p>");
        //     },
        //     onFailure: function(file, response){          // 文件上传失败的回调方法
        //         console.info("此文件上传失败：");
        //         console.info(file.name);
        //     },
        //     onComplete: function(response){           	  // 上传完成的回调方法
        //         console.info("文件上传完成");
        //         console.info(response);
        //     }
        // });

    }

    $("#button1").on("click",function(){
        console.log("ajax表单提交");
        $("#myForm").ajaxSubmit({
            type : 'post', // 提交方式 get/post
            url : '/hy/basic/service/addService', // 需要提交的 url
            data:{"test1":1},
            dataType : 'json',
            success : function(data) {
                if (data.respCode == '0000') {
                    layer.msg('操作成功',{icon: 1,time:1000}, function() {
                        parent.window.location.reload();
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    });

                } else {
                    layer.msg(data.respDesc, {
                        icon : 2,
                        time : 1000
                    });
                }

            }
        });

    });






    var picRecordId1=$("#picRecordId1").val();

    var DemoId=$("#DemoId",window.parent.document).val();
    console.log('DemoId=============='+DemoId);
    /*根据卡类型显示框*/





    layui.use([ 'form'], function() {
    var form=layui.form;

    form.on('select(test)', function(data){
        console.log('进来了2');
        console.log(data.elem); //得到select原始DOM对象
        console.log(data.value); //得到被选中的值
        console.log(data.othis); //得到美化后的DOM对象
        var carType=data.value;

        if(carType == 0){
            $("#pricePerTimeType").show();
            $("#priceType").show();

            $("#priceMarketType").hide();
            $("#timeTotalType").hide();
            $("#priceLabel").text("办卡价格(元)");


        }else if(carType == 1){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }else if(carType == 2){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }else if(carType == 3){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }else if(carType == 4){
            $("#pricePerTimeType").hide();

            $("#priceMarketType").show();
            $("#timeTotalType").show();
            $("#priceLabel").text("优惠价格(元)");
        }

    });

        form.on('select(parentSerSelect)', function(data){
            var parentSerId=data.value;
            $.ajax({
                url:"/hy/basic/serviceSeries/querySonServiceSeries",
                type:"get",
                data:{"recordId":parentSerId},
                dataType:"json",
                success:function(dataJson){
                    var sonSele = $("#serviceSeriesId");//根据id获取select的jquery对象
                    sonSele.find("option").remove();
                    $.each(dataJson.data, function (i, n) {
                        // $("#parentSeriesId").append("<option value='Value'>Text</option>");
                        sonSele.append("<option value="+n.recordId+">"+n.seriesName+"</option>");//添加option
                        console.log(n.seriesName);
                    });

                    renderForm();
                },
                error:function(){
                    alert("驳回异常")
                }
            });
        });
    })





    // layui.use(["jquery", "upload", "form", "layer", "element"], function () {
    //     var $ = layui.$,
    //         element = layui.element,
    //         layer = layui.layer,
    //         upload = layui.upload,
    //         form = layui.form;
    //     //拖拽上传
    //     var recordId=$("#recordId").val();
    //    var  masterDataId=$("#pic1RecordId1").val();
    //     console.log(masterDataId);
    //     var uploadInst = upload.render({
    //         elem: '#headImg1'
    //         , url: '/hy/basic/pictures/uploadPic'
    //         ,data: {"recordType":0,"picType":0,"masterDataId":masterDataId,"recordId":recordId}
    //         , size: 500
    //         , before: function (obj) {
    //             console.log('成功返回');
    //             //预读本地文件示例，不支持ie8
    //             obj.preview(function (index, file, result) {
    //                 $('#demo1').attr('src', result); //图片链接（base64）
    //
    //             });
    //         }
    //         , done: function (res) {
    //             //如果上传失败
    //             if (res.code > 0) {
    //                 return layer.msg('上传失败');
    //             }
    //             //上传成功
    //             //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
    //             /*   console.log(res.data.src);*/
    //             window.parent.uploadHeadImage(res.data.src);
    //             var demoText = $('#demoText1');
    //             demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
    //         }
    //         , error: function () {
    //             //演示失败状态，并实现重传
    //             var demoText = $('#demoText1');
    //             demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
    //             demoText.find('.demo-reload').on('click', function () {
    //                 uploadInst.upload();
    //             });
    //         }
    //     });
    //     element.init();
    // });



    // layui.use(["jquery", "upload", "form", "layer", "element"], function () {
    //     var $ = layui.$,
    //         element = layui.element,
    //         layer = layui.layer,
    //         upload = layui.upload,
    //         form = layui.form;
    //     //拖拽上传
    //     var uploadInst = upload.render({
    //         elem: '#headImg2'
    //         , url: '/hy/basic/pictures/uploadServicePic'
    //         ,data: {"recordType":0,"picType":0}
    //         , size: 500
    //         , before: function (obj) {
    //             console.log('成功返回');
    //             //预读本地文件示例，不支持ie8
    //             obj.preview(function (index, file, result) {
    //                 $('#demo2').attr('src', result); //图片链接（base64）
    //
    //             });
    //         }
    //         , done: function (res) {
    //             //如果上传失败
    //             if (res.code > 0) {
    //                 return layer.msg('上传失败');
    //             }
    //             //上传成功
    //             //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
    //             /*   console.log(res.data.src);*/
    //             window.parent.uploadHeadImage(res.data.src);
    //             var demoText = $('#demoText2');
    //             demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
    //         }
    //         , error: function () {
    //             //演示失败状态，并实现重传
    //             var demoText = $('#demoText2');
    //             demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
    //             demoText.find('.demo-reload').on('click', function () {
    //                 uploadInst.upload();
    //             });
    //         }
    //     });
    //     element.init();
    // });


    layui.use(["jquery", "upload", "form", "layer", "element"], function () {

        element = layui.element,
            layer = layui.layer,
            upload = layui.upload,
            form = layui.form;
        //拖拽上传
        var  recordId=$("#picRecordId1").val();
        console.log('上传recordId'+recordId);
        var masterDataId=12;

        var uploadInst = upload.render({

            elem: '#headImg1'
            , url: '/hy/basic/pictures/uploadPicForPC'
            ,data: {"recordType":0,"picType":0,"masterDataId":$("#picRecordId1").val(),"recordId":recordId}
            , size: 500
            , before: function (obj) {
                console.log('成功返回');

                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）

                });
            }
            , done: function (res) {
                console.log(res.msg);
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
                /*   console.log(res.data.src);*/
                window.parent.uploadHeadImage(res.data.src);
                var demoText = $('#demoText1');
                demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText1');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        element.init();
    });


    layui.use(['element', 'layer', 'jquery','form','laydate','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var laydate=layui.laydate;
        /* function quxiao(){
            alert(111);
        } */
        var $ = layui.jquery,
            upload = layui.upload;

        form.on('submit(*)', function(data){
            console.log(data.field);
            if(data.field.recordStatus=='on'){
                data.field.recordStatus = 1
            }else{
                data.field.recordStatus = 0;
            }

            var url = '/hy/basic/service/updateService';

            $.ajax({
                type:'POST',
                url:url,
                data: data.field,
                success: function(data){
                    alert("操作成功！");
                    window.parent.location.reload(); //刷新父页面
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);  // 关闭layer
                    /* alert("操作成功");
                    if(type=="update"){
                        window.parent.location.reload(); //刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);  // 关闭layer
                    }else{
                        window.location.reload();
                        //window.location.href="${basePath}ryOrderConfig/queryList";
                    } */

                    //window.location.href="${basePath}ryOrderConfig/queryList";
                },
                error:function(data){
                    alert("操作失败");
                    console.log(data);
                }
            })
            return false;
        });

    })






</script>  